package com.victor.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.victor.entity.JQActiviClassone;
import com.victor.entity.JQActiviClasstwo;
import com.victor.entity.JQActivity;
import com.victor.entity.JQActivityTime;
import com.victor.service.JingquActivityService;
import com.victor.utils.Msg;

/**
 * 景区演艺活动管理
 * 
 * @author zhangbin
 *
 */
@RestController
@RequestMapping("/jqactivity")
public class JingquActivityController {

	@Autowired
	private JingquActivityService service;

	// 获取第一分类
	@RequestMapping("/getClassOne")
	public Msg getClassOne() {
		List<JQActiviClassone> jqActiviClassones = service.getClassOne();
		return Msg.success().add("jqActiviClassones", jqActiviClassones);
	}

	// 获取第二分类
	@RequestMapping("/getClassTwo")
	public Msg getClassTwo(String classoneid) {
		List<JQActiviClasstwo> jqActiviClasstwos = service.getClassTwo(classoneid);
		return Msg.success().add("jqActiviClasstwos", jqActiviClasstwos);
	}

	// 获取景区活动列表(景区id)
	@RequestMapping("/getJQactivity")
	public Msg getJQactivity(String jqid) {
		List<JQActivity> jqActivities = service.getJQactivity(jqid);
		return Msg.success().add("jqActivities", jqActivities);
	}

	// 新建景区活动
	@RequestMapping("/buildJQactivity")
	public Msg buildJQactivity(@RequestBody JQActivity jqActivity) {
		if (jqActivity == null) {
			return Msg.fail("参数错误");
		}
		boolean insResult = service.buildJQactivity(jqActivity);
		if (jqActivity.getJqActivityTimes() != null && jqActivity.getJqActivityTimes().size() > 0) {
			for (JQActivityTime jqActivityTime : jqActivity.getJqActivityTimes()) {
				jqActivityTime.setJqacid(String.valueOf(jqActivity.getId()));
				service.buildJQactivityTime(jqActivityTime);
			}
		}
		return Msg.judge(insResult);
	}

	// 修改景区活动
	@RequestMapping("/updateJQactivity")
	public Msg updateJQactivity(JQActivity jqActivity) {
		boolean updResult = service.updateJQactivity(jqActivity);
		return Msg.judge(updResult);
	}

	// 批量删除景区活动
	@RequestMapping("/deleteJQactivity")
	public Msg deleteJQactivity(int[] jqActivitys) {
		boolean delResult = service.deleteJQactivity(jqActivitys);
		return Msg.judge(delResult);
	}
}
